<?php
                class office_has_family_model extends CI_Model {
                    function __construct(){
                        parent::__construct();
                        $this->tableName = "office_has_family";
                    }
                    function insert($office_officeid, $family_familyid, $family_userid, $family_familitypeid){
                        $dt = array("office_officeid" => $office_officeid, 
                        "family_familyid" => $family_familyid, 
                        "family_userid" => $family_userid, 
                        "family_familitypeid" => $family_familitypeid);
                        $this->db->insert($this->tableName, $dt);
                        return $this->db->insert_id();
                    }
                    
                    function update($office_officeid, $family_familyid, $family_userid, $family_familitypeid, $dt, $where=""){
                        $this->db->where("office_officeid", $office_officeid);
                        $this->db->where("family_familyid", $family_familyid);
                        $this->db->where("family_userid", $family_userid);
                        $this->db->where("family_familitypeid", $family_familitypeid);
                        if($where != "")$this->db->where($where);
                        $this->db->update($this->tableName, $dt);
                    }
                    
                    function delete($office_officeid, $family_familyid, $family_userid, $family_familitypeid,  $where = ""){
                        $this->db->where("office_officeid", $office_officeid);
                        $this->db->where("family_familyid", $family_familyid);
                        $this->db->where("family_userid", $family_userid);
                        $this->db->where("family_familitypeid", $family_familitypeid);
                        if($where != "")$this->db->where($where);
                        $this->db->delete($this->tableName);
                    }
                    
                    function getById($office_officeid, $family_familyid, $family_userid, $family_familitypeid,  $where=""){
                        $this->db->where("office_officeid", $office_officeid);
                        $this->db->where("family_familyid", $family_familyid);
                        $this->db->where("family_userid", $family_userid);
                        $this->db->where("family_familitypeid", $family_familitypeid);
                        if($where != "")$this->db->where($where);
                        return $this->db->get($this->tableName)->row();
                    }
                    
                    function getAll($startpage="0", $perpage="10", $where = "", $orderby=""){
                        if($where != "")$this->db->where($where);
                        $this->db->limit($perpage, $startpage);
                        if($orderby != "")$this->db->order_by($orderby);
                        return $this->db->get($this->tableName)->result();
                    }
                    
                    function getAllCount($where = ""){
                        $this->db->select("COUNT(*) JUMLAH");
                        $this->db->from($this->tableName);
                        if($where != "")$this->db->where($where);
                        return $this->db->get()->row()->JUMLAH;
                    }
                }
                ?>